<?php

/**
 * product actions.
 *
 * @package    Serag
 * @subpackage product
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class productActions extends sfActions {

    /**
     * Executes index action
     *
     * @param sfRequest $request A request object
     */
    public function executeIndex(sfWebRequest $request) {
        $this->products = Doctrine::getTable("Product")->createQuery('a')->where('id > 0')->orderBy('id DESC')->execute();
    }

    public function executeAddProduct(sfWebRequest $request) {
        $this->form = new ProductForm();

        if ($request->isMethod(sfRequest::POST)) {
            $this->form->bind($request->getParameter($this->form->getName()),$request->getFiles($this->form->getName()));

            if ($this->form->isValid()) {
                $product = new Product();
                $product->fromArray($request->getParameter($this->form->getName()));
                $product->save();
                return $this->renderText('Done');
            }
        }
    }

    public function executeShow(sfWebRequest $request) {
        
    }

}
